<?php
namespace App\Module\Admin\Request\Foot;

use App\Constants\Constant;
use Hyperf\Validation\Request\FormRequest;
use Hyperf\Validation\Rule;

class CreateRequest extends FormRequest{

    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'child_id'=>'required|exists:child,child_id',
            'is_public'=>['required',Rule::in([Constant::FOOT_PRIVATE,Constant::FOOT_PUBLIC])],
            'is_excellent'=>'required|in:1,2',
            'source'=>['required',Rule::in([Constant::SOURCE_ADMIN,Constant::SOURCE_TEACHER,Constant::SOURCE_USER])],
            'source_id'=>'required_if:source,2,3',
            'content'=>'required_without:resources',
            'resources'=>'required_without:content|array',
            'resources.*'=>'url',
            'resource_type'=>['required_with:resources',Rule::in([Constant::RESOURCE_TYPE_PICTURE,Constant::RESOURCE_TYPE_VIDEO])]
        ];
    }
}